# -*- coding: utf-8 -*-
"""
B站视频下载器配置文件
包含应用的所有配置参数和常量定义
"""

import os
from pathlib import Path

# 应用基本信息
APP_NAME = "B站视频下载器"
APP_VERSION = "1.0.0"
APP_AUTHOR = "开发者"

# 窗口配置
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600
WINDOW_TITLE = f"{APP_NAME} v{APP_VERSION}"
WINDOW_RESIZABLE = False
FPS = 60

# 路径配置
BASE_DIR = Path(__file__).parent.parent
LOGS_DIR = BASE_DIR / "logs"
DOWNLOADS_DIR = BASE_DIR / "downloads"
CONFIG_DIR = BASE_DIR / "config"

# 确保目录存在
LOGS_DIR.mkdir(exist_ok=True)
DOWNLOADS_DIR.mkdir(exist_ok=True)

# 下载配置
DEFAULT_DOWNLOAD_PATH = str(DOWNLOADS_DIR)
MAX_CONCURRENT_DOWNLOADS = 3
DOWNLOAD_TIMEOUT = 30  # 秒
RETRY_TIMES = 3

# 网络配置
REQUEST_TIMEOUT = 10  # 秒
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"

# B站相关配置
BILIBILI_DOMAINS = [
    "bilibili.com",
    "b23.tv",
    "www.bilibili.com"
]

# 支持的视频质量
VIDEO_QUALITY_OPTIONS = {
    "1080P": "1080",
    "720P": "720",
    "480P": "480",
    "360P": "360"
}

# 日志配置
LOG_LEVEL = "INFO"
LOG_FILE = LOGS_DIR / "app.log"
MAX_LOG_SIZE = 10 * 1024 * 1024  # 10MB
LOG_BACKUP_COUNT = 5

# UI布局配置
UI_PADDING = 10
UI_MARGIN = 5

# URL输入区域
URL_INPUT_HEIGHT = 80
URL_INPUT_LABEL_WIDTH = 80
URL_INPUT_BOX_WIDTH = 600
URL_PARSE_BUTTON_WIDTH = 120

# 视频信息区域
VIDEO_INFO_HEIGHT = 120

# 下载设置区域
DOWNLOAD_SETTINGS_HEIGHT = 80
PATH_DISPLAY_WIDTH = 500
BROWSE_BUTTON_WIDTH = 80

# 控制按钮区域
CONTROL_BUTTONS_HEIGHT = 60
BUTTON_WIDTH = 100
BUTTON_HEIGHT = 35
BUTTON_SPACING = 10

# 日志显示区域
LOG_DISPLAY_HEIGHT = 250

# 文件配置
SUPPORTED_VIDEO_FORMATS = [".mp4", ".flv", ".avi", ".mkv"]
DEFAULT_VIDEO_FORMAT = ".mp4"

# 错误消息
ERROR_MESSAGES = {
    "INVALID_URL": "请输入有效的B站视频链接",
    "NETWORK_ERROR": "网络连接失败，请检查网络设置",
    "DOWNLOAD_FAILED": "下载失败，请重试",
    "PATH_NOT_EXISTS": "下载路径不存在，请选择有效路径",
    "INSUFFICIENT_SPACE": "磁盘空间不足",
    "PERMISSION_DENIED": "没有写入权限，请选择其他路径"
}

# 成功消息
SUCCESS_MESSAGES = {
    "DOWNLOAD_COMPLETE": "下载完成！",
    "VIDEO_INFO_LOADED": "视频信息获取成功",
    "PATH_SELECTED": "路径选择成功"
}

# 调试模式
DEBUG = True

# 开发者选项
DEV_OPTIONS = {
    "show_fps": False,
    "show_debug_info": False,
    "enable_console_log": True
}